window.onload=function(){
    // // 点击收货地址跳转
    var address_1=document.querySelector(".user-news-box-1-1");
    address_1.addEventListener("click",function(){
        window.location.href="/addressPage";
    });
    var address_2=document.querySelector(".user-news-box-1-2");
    address_2.addEventListener("click",function(){
        window.location.href="/addressPage";
    });
    // 点击跳转个人资料
    var address_3=document.querySelector(".user-news-box-2-1");
    address_3.addEventListener("click",function(){
        window.location.href="/User/userInformation";
    });
    var address_4=document.querySelector(".user-name");
    address_4.addEventListener("click",function(){
        window.location.href="/User/userInformation";
    });
    // 点击跳转我已买到的宝贝
    var main_left_nav_3=document.querySelector(".main-left").children[2];
    main_left_nav_3.addEventListener("click", function () {
        window.location.href="/User/allGoods";
    });
    // 跳转到首页
    var all_main=document.querySelector(".nav-top-box-1").children[0]
    all_main.addEventListener("click", function () {
        window.location.href="/";
    });
    // 跳转到登录页面或者个人中心
    var nav_top_box_2=document.querySelector(".nav-top-box-2").children[0];
    var text_1=nav_top_box_2.innerHTML;
    console.log(text_1)
    nav_top_box_2.addEventListener("click",function() {
        if (text_1 == "登录") {
            window.location.href = "/User/login";
        } else {
            window.location.href = "/User/userInterface";
        }
    })
    // 跳转到购物车
    var shoppingcar=document.querySelector(".shoppingcar");
    shoppingcar.addEventListener("click",function () {
        window.location.href = "/User/myCarPage";
    })
    // 跳转到我的喜欢
    var mylike=document.querySelector(".mylike");
    mylike.addEventListener("click",function(){
        window.location.href = "/User/myLike";
    })
    // 点击跳转修改密码
var change=document.querySelector(".changepassword");
    change.onclick=function () {
        window.location.href = "/User/updatePassword"
    }
    //点击退出跳转到主页
    var exit= document.querySelector(".exit")
    exit.addEventListener("click",function(){
        $.ajax({
            type: "post",
            url: "/User/loginOut",
            // data: {
            // },
            success: function (data) {
                // alert("退出")
                window.location.href="/";

            },error: function () {
                console.log("調取接口失敗")
            }
        })
    })
    // 点击待付款,待收货...
    var user_nav=document.querySelectorAll(".user-news-2-nav")
    user_nav[0].addEventListener("click",function() {
        window.location.href="/User/waitPay";
    })
    user_nav[1].addEventListener("click",function() {
        window.location.href="/User/sendGoods";
    })
    user_nav[2].addEventListener("click",function() {
        window.location.href="/User/getGoods";
    })
    user_nav[3].addEventListener("click",function() {
        window.location.href="/User/waitAssess";
    })

    // 账户设置隐藏显示
    var header_hidden=document.querySelector(".header-hidden");
    var number_fit=document.querySelector(".header-box-1").children[1];
    var q=document;
    console.log(header_hidden);
    number_fit.addEventListener("mouseover",function(){
        header_hidden.style.display="block";
    });
     q.addEventListener("click",function(){
         header_hidden.style.display="none";
    });
    header_hidden.addEventListener("click",function(e){
        e.stopPropagation();
    })
    // 如果显示的是登录就点击跳转登录
    var user_Name=document.querySelector(".user-name");
    if(user_Name.innerHTML=="登录"){
        user_Name.addEventListener("click",function(){
            window.location.href="/User/login";
        })
    }
    // 否则就跳转到个人资料
    else{
        user_Name.addEventListener("click",function(){
            window.location.href="/User/userInformation";
        })
    }
}